
$(document).ready(function() {
	$("#category").keyup(function() {
		var dInput = $('input:text[name=category]').val();
		$f = seo_url(dInput);
		// alert ($f);

		$('#seourl').val($f);
		// console.log(dInput);
	});

});

$(document).ready(function() {
	$("#location").keyup(function() {
		var dInput = $('input:text[name=location]').val();
		$f = seo_url(dInput);
		// alert ($f);

		$('#seourl').val($f);
		// console.log(dInput);
	});

});



function seo_url(name) {
	name = name.toLowerCase(); // lowercase
	name = name.replace(/^\s+|\s+$/g, ''); // remove leading and trailing//
	// whitespaces
	name = name.replace(/\s+/g, '-'); // convert (continuous) whitespaces to
	// // one -
	name = name.replace(/[^a-z0-9]+/g, "-");
	return name;
}

$(document).ready(function() {
	$('#category').change(function() {
		$("#brand > option").remove();

		var catID = $('#category').val();
		// alert(catID);

		$("#brand").removeAttr('disabled');

		var base_url = $('body').data('baseurl');
		var path = base_url + "secure/category/AjaxBrand/" + catID;

		 //alert(path);

		$.ajax({
			type : "POST",
			url : path,

			success : function($brand) {
				// alert($brand);
				var opt1 = $('<option />');
				opt1.val(0);
				opt1.text("--Select Brand--");
				$('#brand').append(opt1);
				$.each($brand, function(id, name) {
					var opt = $('<option />');
					opt.val(id);
					opt.text(name);
					$('#brand').append(opt);
				});
			}
		});
	});
});

$(document).ready(function() {
	$('#brand').change(function() {
		$("#type > option").remove();

		var catID = $('#brand').val();
		// alert(catID);

		$("#type").removeAttr('disabled');

		var base_url = $('body').data('baseurl');
		var path = base_url + "secure/brand/AjaxType/" + catID;

		//alert(path);

		$.ajax({
			type : "GET",
			url : path,

			success : function($series) {
				// alert($brand);
				var opt1 = $('<option />');
				opt1.val(0);
				opt1.text("--Select Series--");
				$('#type').append(opt1);
				$.each($series, function(id, name) {
					var opt = $('<option />');
					opt.val(id);
					opt.text(name);
					$('#type').append(opt);
				});
			}
		});
	});
});

$(document).ready(function() {
	$('#type').change(function() {
		$("#series > option").remove();

		var catID = $('#type').val();
		// alert(catID);

		$("#series").removeAttr('disabled');

		var base_url = $('body').data('baseurl');
		var path = base_url + "secure/brand/AjaxSeries/" + catID;

		//alert(path);

		$.ajax({
			type : "GET",
			url : path,

			success : function($series) {
				// alert($brand);
				var opt1 = $('<option />');
				opt1.val(0);
				opt1.text("--Select Series--");
				$('#series').append(opt1);
				$.each($series, function(id, name) {
					var opt = $('<option />');
					opt.val(id);
					opt.text(name);
					$('#series').append(opt);
				});
			}
		});
	});
});



